package com.punai.dataclean.controller;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.dataclean.constants.IncomeDataConstanta;
import com.punai.dataclean.domain.vo.CostDataCleanVo;
import com.punai.dataclean.domain.vo.IncomeDataCleanVo;
import com.punai.dataclean.service.IncomeDataCleanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dataclean/incomedataclean")
public class IncomeDataCleanController extends BaseController {

    @Autowired
    private IncomeDataCleanService incomeDataCleanService;

    /**
     * 查询页签列表
     */
    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:getTabs')")
    @GetMapping("/getTabs")
    public AjaxResult getTabs() {
        return AjaxResult.success(IncomeDataConstanta.Tabs.getAllTab());
    }

    /**
     * 查询树数据
     */
    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:getTabs')")
    @GetMapping("/getTreeData")
    public AjaxResult getTreeData(IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return AjaxResult.success(incomeDataCleanService.getTreeData(vo));
    }

    /**
     * 查询所有价格类型
     */
    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:getAllPriceType')")
    @GetMapping("/getAllPriceType")
    public AjaxResult getAllPriceType() {
        return AjaxResult.success(IncomeDataCleanService.IncomeProjectTypeKV);
    }


    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:getGroupTableData')")
    @GetMapping("/getGroupTableData")
    public TableDataInfo getGroupTableData(IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return incomeDataCleanService.getGroupTableData(vo);
    }

    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:getDetailTableData')")
    @GetMapping("/getDetailTableData")
    public AjaxResult getDetailTableData(IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return AjaxResult.success(incomeDataCleanService.getDetailTableData(vo));
    }

    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:claen')")
    @PostMapping("/enterClean")
    public AjaxResult enterClean(@RequestBody IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return AjaxResult.success(incomeDataCleanService.enterClean(vo));
    }

    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:claen')")
    @GetMapping("/allEnterClean")
    public AjaxResult allEnterClean(IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return AjaxResult.success(incomeDataCleanService.allEnterClean(vo));
    }

    @PreAuthorize("@ss.hasPermi('dataclean:incomedataclean:claen')")
    @GetMapping("/getInventoryData")
    public TableDataInfo getInventoryData(IncomeDataCleanVo vo) {
        vo.setCompanyId(getCompanyId());
        return incomeDataCleanService.getInventoryData(vo);
    }
}
